package com.wjh.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wjh.mapper.ExpressageOrderMapper;
import com.wjh.pojo.Expressage;
import com.wjh.pojo.ExpressageOrder;
import com.wjh.service.ExpressageOrderService;
import com.wjh.utils.ResponseResult;
import com.wjh.vo.PageVo;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (ExpressageOrder)表服务实现类
 *
 * @author makejava
 * @since 2024-03-10 21:35:42
 */
@Service("expressageOrderService")
public class ExpressageOrderServiceImpl extends ServiceImpl<ExpressageOrderMapper, ExpressageOrder> implements ExpressageOrderService {

    @Override
    public ResponseResult getOrderListAll(Integer pageNum, Integer pageSize, String phone, String orderNumber, String consignerName, String createTime) {
        LambdaQueryWrapper<ExpressageOrder> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(phone!=null,ExpressageOrder::getPhone,phone);
        queryWrapper.like(orderNumber!=null,ExpressageOrder::getOrderNumber,orderNumber);
        queryWrapper.like(consignerName!=null,ExpressageOrder::getConsignerName,consignerName);
        queryWrapper.eq(createTime != null,ExpressageOrder::getCreateTime,createTime);
        //分页查询所有
        Page<ExpressageOrder> expressageOrderPage = new Page<>(pageNum,pageSize);
        Page<ExpressageOrder> page = page(expressageOrderPage, queryWrapper);
        List<ExpressageOrder> records = page.getRecords();
        return ResponseResult.okResult(new PageVo(records,page.getTotal()));
    }

    @Override
    public ResponseResult addOrderCreate(Expressage expressage) {
        return null;
    }

    @Override
    public ResponseResult delOrderById(List<Integer> id) {
        removeByIds(id);
        return ResponseResult.okResult();
    }
}
